﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LightWeb.Infrastructure.Repositories;
using LightWeb.MvcWeb.Areas.Dashboard.Models;

namespace LightWeb.MvcWeb.Areas.Dashboard.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Dashboard/Home/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult About()
        {
            return View();
        }

        [HttpPost]
        public ActionResult DbMaintain(FormCollection collection)
        {
            try
            {
                DataContext.ReCreateDatabase();
                DataContext.ForceInit();
                return View(new DbMaintainModel { Msg = "Successful" });
            }
            catch (Exception ex)
            {
                return View(new DbMaintainModel { Msg = ex.FullMsg() });
            }
        }

        [HttpGet]
        public ActionResult DbMaintain()
        {
            return View(new DbMaintainModel { Msg = "" });
        }
    }
}
